<?php
Load::models('rol');
 
class RolController extends ApplicationController {
 
    public function index(){
        
    }
 
    public function agregar ()
    {
        
        if(Input::hasPost('rol')){
           
            $rol = new Rol(Input::post('rol'));
            
             if(!$rol->save()){
                Flash::error('Falló Operación');
                
                $this->rol = $this->post('rol');
              
            }else{
                Flash::success('Operación exitosa');
            }
        }
    }
    public function editar(){
        
    }
    public function eliminar($id){
   
       $rol = new Rol();
       $rol = $rol->find($id);
       $rol->estado = "0";
            
       if ($rol->update()) {
            Flash::valid('Operación exitosa');
       }else{
           Flash::error('Falló Operación'); 
       }
        return Router::redirect('rol/listar');
   
    }
    public function listar(){
        $rol = new Rol();
        $this->rol =   $rol->find("order: nombre");   
    }
 
    
}
?>